package com.mapper;

import com.bean.ArticleInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Yuicon on 2016/11/3.
 */
public interface ArticleInfoMapper {

    @Select("select id,aaid,title,uploader,addTime,synopsis,onlookerNum,commentNum from tb_articleInfo where aaid = #{aaid}")
    List<ArticleInfo> findAll(String aaid);

    @Select("select id,aaid,title,uploader,addTime,synopsis,onlookerNum,commentNum from tb_articleInfo where id = #{id}")
    ArticleInfo findById(String id);

    @Insert("insert into tb_articleInfo (id,aaid,title,uploader,addTime,synopsis,onlookerNum,commentNum) values(#{id},#{aaid},#{title},#{uploader},#{addTime},#{synopsis},#{onlookerNum},#{commentNum})")
    void insert(ArticleInfo articleInfo);

    @Update("update tb_articleInfo set title=#{title},synopsis=#{synopsis},onlookerNum=#{onlookerNum},commentNum=#{commentNum} where id=#{id}")
    void update(ArticleInfo articleInfo);
}
